package com.wavecoler.coach.objects;


import java.util.ArrayList;
import java.util.List;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.Inheritance;
import javax.jdo.annotations.InheritanceStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;


import com.google.appengine.api.datastore.Key;

@PersistenceCapable
//@Inheritance(strategy=InheritanceStrategy.SUBCLASS_TABLE) //added this

public class Node {
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key nodeId;
	
	@Persistent
	protected String nodeWaveId;
	
	@Persistent
	protected String label;
	
	@Persistent
	protected String type; //E:Entity, R:Relationship, A:Attribute, G:Generalization
	
	@Persistent
	protected Graph graph;
	
	@Persistent
	protected String subtype;
	
	@Persistent
	protected List <String> attributes;
	
	//Solo Para Relaciones
	@Persistent(mappedBy = "node")
    private List<RelationNode> relationNodes = new ArrayList<RelationNode>();
	
	public List<RelationNode> getRelationNodes() {
		return relationNodes;
	}

	public void setRelationNodes(List<RelationNode> relationNodes) {
		this.relationNodes = relationNodes;
	}
	
	//Solo para Attributos
	@Persistent
	protected String parentNode; //wave id del nodo al que pertenece.

	
	
	
	
	//Getters & Setters 
	public Key getNodeId() {
		return nodeId;
	}
	
	public void setNodeId(Key nodeId) {
		this.nodeId = nodeId;
	}

	public String getNodeWaveId() {
		return nodeWaveId;
	}

	public void setNodeWaveId(String nodeWaveID) {
		this.nodeWaveId = nodeWaveId;
	}
	
	
	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		this.label = label;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public Graph getGraph() {
		return graph;
	}

	public void setGraph(Graph graph) {
		this.graph = graph;
	}
	
	public String getSubtype() {
		return subtype;
	}

	public void setSubtype(String subtype) {
		this.subtype = subtype;
	}

	public List<String> getAttributes() {
		return attributes;
	}

	public void setAttributes(List<String> attributes) {
		this.attributes = attributes;
	}
	
	public String getParentNode() {
		return parentNode;
	}

	public void setParentNode(String parentNode) {
		this.parentNode = parentNode;
	}
	
	/*public RelationNode getRelationNodeById(String id, Graph graph){
		List <Node> relations = graph.getNodesByType("relation");
		for (int i = 0; i < relations.size(); i++){
			List <RelationNode> relationNode = relations.get(i).getRelationNodes();
			for (int y = 0; y < relationNode.size(); y++){
				relationNode.get(y).getRelationNodeID();
			}
		}
		
		
		return null;
	}*/

	//Constructors
	public Node(String nodeWaveId, String label, String type, Graph graph) {
		super();
		this.nodeWaveId = nodeWaveId;
		this.label = label;
		this.type = type;
		this.graph = graph;
	}
	
	public Node(String nodeWaveId, String label, String type, String subtype, Graph graph) {
		super();
		this.nodeWaveId = nodeWaveId;
		this.label = label;
		this.type = type;
		this.subtype = subtype;
		this.graph = graph;
	}
	
	public Node(String nodeWaveId, String label, String type, String subtype, String parentNode, Graph graph) {
		super();
		this.nodeWaveId = nodeWaveId;
		this.label = label;
		this.type = type;
		this.subtype = subtype;
		this.parentNode = parentNode;
		this.graph = graph;
	}
	
	public Node(String label, Graph graph) {
		super();
		this.label = label;
		this.graph = graph;
	}
	
	public Node(String label, String type) {
		super();
		this.label = label;
		this.type = type;
	}
	
	  public Node(String label, String type, Graph graph) {
          super();
          this.label = label;
          this.type = type;
          this.graph = graph;
  }
  
	
	public Node(){
	}
	
	//currentObject para el difer
	public Node(String nodeWaveId, String label, String type, String subtype) {
		super();
		this.nodeWaveId = nodeWaveId;
		this.label = label;
		this.type = type;
		this.subtype = subtype;
	}
	
	public Node(String nodeWaveId, String label, String type) {
		super();
		this.nodeWaveId = nodeWaveId;
		this.label = label;
		this.type = type;
	}
	
	//solo para relaciones
	public Node(String nodeWaveId, String label, String type, Graph graph, List<String> attributes ) {
		super();
		this.nodeWaveId = nodeWaveId;
		this.label = label;
		this.type = type;
		this.attributes = attributes;
	}
}
